-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb][NFC] Replace const std::vector& with ArrayRef in APIs #170834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Inside the LLVM codebase, const vector& should just be ArrayRef, as this more general API works both with vectors, SmallVectors and SmallVectorImpl, as well as with single elements. This commit replaces two uses introduced in llvm#168797 .
|
@llvm/pr-subscribers-lldb Author: Felipe de Azevedo Piovezan (felipepiovezan) ChangesInside the LLVM codebase, const vector& should just be ArrayRef, as this more general API works both with vectors, SmallVectors and SmallVectorImpl, as well as with single elements. This commit replaces two uses introduced in Full diff: https://github.com/llvm/llvm-project/pull/170834.diff 4 Files Affected:
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 96ae8364c94e5..40ce23e3d2ffb 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -298,29 +298,12 @@ class Module : public std::enable_shared_from_this<Module>,
/// matches.
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list);
- /// Find functions by lookup info.
- ///
- /// If the function is an inlined function, it will have a block,
- /// representing the inlined function, and the function will be the
- /// containing function. If it is not inlined, then the block will be NULL.
- ///
- /// \param[in] lookup_info
- /// The lookup info of the function we are looking for.
- ///
- /// \param[out] sc_list
- /// A symbol context list that gets filled in with all of the
- /// matches.
- void FindFunctions(const LookupInfo &lookup_info,
- const CompilerDeclContext &parent_decl_ctx,
- const ModuleFunctionSearchOptions &options,
- SymbolContextList &sc_list);
-
/// Find functions by a vector of lookup infos.
///
/// If the function is an inlined function, it will have a block,
/// representing the inlined function, and the function will be the
/// containing function. If it is not inlined, then the block will be NULL.
- void FindFunctions(const std::vector<LookupInfo> &lookup_infos,
+ void FindFunctions(llvm::ArrayRef<LookupInfo> lookup_infos,
const CompilerDeclContext &parent_decl_ctx,
const ModuleFunctionSearchOptions &options,
SymbolContextList &sc_list);
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h
index 305eb0f201b37..9982852cc760d 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -309,10 +309,9 @@ class SymbolFile : public PluginInterface {
virtual void FindFunctions(const Module::LookupInfo &lookup_info,
const CompilerDeclContext &parent_decl_ctx,
bool include_inlines, SymbolContextList &sc_list);
- virtual void
- FindFunctions(const std::vector<Module::LookupInfo> &lookup_infos,
- const CompilerDeclContext &parent_decl_ctx,
- bool include_inlines, SymbolContextList &sc_list);
+ virtual void FindFunctions(llvm::ArrayRef<Module::LookupInfo> lookup_infos,
+ const CompilerDeclContext &parent_decl_ctx,
+ bool include_inlines, SymbolContextList &sc_list);
virtual void FindFunctions(const RegularExpression ®ex,
bool include_inlines, SymbolContextList &sc_list);
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index eb2f95b105a5d..da2c188899f03 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -820,33 +820,24 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
}
}
-void Module::FindFunctions(const Module::LookupInfo &lookup_info,
+void Module::FindFunctions(llvm::ArrayRef<Module::LookupInfo> lookup_infos,
const CompilerDeclContext &parent_decl_ctx,
const ModuleFunctionSearchOptions &options,
SymbolContextList &sc_list) {
- // Find all the functions (not symbols, but debug information functions...
- if (SymbolFile *symbols = GetSymbolFile()) {
+ for (auto &lookup_info : lookup_infos) {
+ SymbolFile *symbols = GetSymbolFile();
+ if (!symbols)
+ continue;
+
symbols->FindFunctions(lookup_info, parent_decl_ctx,
options.include_inlines, sc_list);
- // Now check our symbol table for symbols that are code symbols if
- // requested
- if (options.include_symbols) {
- if (Symtab *symtab = symbols->GetSymtab()) {
+ if (options.include_symbols)
+ if (Symtab *symtab = symbols->GetSymtab())
symtab->FindFunctionSymbols(lookup_info.GetLookupName(),
lookup_info.GetNameTypeMask(), sc_list);
- }
- }
}
}
-void Module::FindFunctions(const std::vector<Module::LookupInfo> &lookup_infos,
- const CompilerDeclContext &parent_decl_ctx,
- const ModuleFunctionSearchOptions &options,
- SymbolContextList &sc_list) {
- for (auto &lookup_info : lookup_infos)
- FindFunctions(lookup_info, parent_decl_ctx, options, sc_list);
-}
-
void Module::FindFunctions(ConstString name,
const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask,
diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp
index 2aea802b6c826..bfc63003216b2 100644
--- a/lldb/source/Symbol/SymbolFile.cpp
+++ b/lldb/source/Symbol/SymbolFile.cpp
@@ -126,10 +126,10 @@ void SymbolFile::FindFunctions(const Module::LookupInfo &lookup_info,
bool include_inlines,
SymbolContextList &sc_list) {}
-void SymbolFile::FindFunctions(
- const std::vector<Module::LookupInfo> &lookup_infos,
- const CompilerDeclContext &parent_decl_ctx, bool include_inlines,
- SymbolContextList &sc_list) {
+void SymbolFile::FindFunctions(llvm::ArrayRef<Module::LookupInfo> lookup_infos,
+ const CompilerDeclContext &parent_decl_ctx,
+ bool include_inlines,
+ SymbolContextList &sc_list) {
for (const auto &lookup_info : lookup_infos)
FindFunctions(lookup_info, parent_decl_ctx, include_inlines, sc_list);
}
|
augusto2112
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks!
Inside the LLVM codebase, const vector& should just be ArrayRef, as this more general API works both with vectors, SmallVectors and SmallVectorImpl, as well as with single elements.
This commit replaces two uses introduced in
#168797 .